package javawdw.picture.api;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javawdw.picture.exception.DecodeException;
import javawdw.picture.exception.EncodeException;

public interface PictureCodec<E extends Picture> {

	/**
	 * 将给定的输入流解码
	 * 
	 * @param inputStream
	 *            给定的输入流
	 * @return 解码得到的Pictrue对象
	 * @throws DecodeException
	 */
	public E decode(InputStream inputStream) throws IOException,
			DecodeException;

	/**
	 * 将给定Picture对象编码写入输出流
	 * 
	 * @param picture
	 *            给定Picture对象
	 * @param outputStream
	 *            给定输出流
	 */
	public void encode(E picture, OutputStream outputStream)
			throws IOException, EncodeException;

	/**
	 * 获得给定Picture编码后大小
	 * 
	 * @param picture
	 *            给定图片
	 * @return 返回图片大小
	 */
	public long getByteSize(E picture) throws EncodeException;
}